﻿@using Microsoft.Extensions.Options
﻿@using CalmLog.Web.Options
@using RuoVea.ExEnum
@using RuoVea.OmiApi.Article.Entitys
@using RuoVea.OmiApi.Article.Service
@using RuoVea.OmiApi.Article.Service.Dto
@using RuoVea.OmiApi.Dict.Entitys
@using RuoVea.OmiApi.Dict.Service
@inject IOptionsMonitor<SystemInfo> systemInfo;
@inject IOptionsMonitor<OrgInfo> orgInfo;
@inject ArticleService articleService; 
@inject CategoryArticleService categoryArticleService;
@inject CategoryService categoryService;
@inject TagService tagService;
@inject SysDictValueService sysDictValueService;
@{
    var categoryList = categoryService.GetList(new CategoryParam { PageNo = 1, PageSize = 10, IsDisable = YesOrNot.N });
    var tagList =await tagService.GetList();
    var articleList =  articleService.GetList(new ArticleParam { CategorieIsDisable = YesOrNot.N, PageNo = 1, PageSize = 10 });
    long articleId = (categoryArticleService.GetList(new CategoryParam { Code="about", IsDisable= YesOrNot.N }))?.Select(x=>x.ArticleId).FirstOrDefault()??0;

    List<SysDictValue> rihtcard = await sysDictValueService.GetDictDataListByCodeCache("RIHTCARD");
    var wechart = rihtcard.Where(x => x.Code == "wechart").FirstOrDefault();
    var newrecomm = rihtcard.Where(x => x.Code == "NEWRECOMM").FirstOrDefault();
    List<SysDictValue> systemInfo2 = await sysDictValueService.GetDictDataListByCodeCache("SYSTEMINFO");
    var Title = systemInfo2.Where(x => x.Code == "Title").Select(x => x.ExtData).FirstOrDefault();
    var Keywords = systemInfo2.Where(x => x.Code == "Keywords").Select(x => x.ExtData).FirstOrDefault();
    var Description = systemInfo2.Where(x => x.Code == "Description").Select(x => x.ExtData).FirstOrDefault();
    var CopyRigth = systemInfo2.Where(x => x.Code == "CopyRigth").Select(x => x.Value).FirstOrDefault();
    var Logo = systemInfo2.Where(x => x.Code == "Logo").Select(x => x.ExtData).FirstOrDefault();
}
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>@Html.Raw(Title??systemInfo.CurrentValue.Title)</title>
    <meta name="keywords" content="@Html.Raw(Keywords)">
    <meta name="description" content="@Html.Raw(Description)">
    <link href="~/lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="~/lib/css/cl-css.css" rel="stylesheet">
    <link href="~/lib/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="~/lib/highlight/styles/railscasts.css" rel="stylesheet">
    @await RenderSectionAsync("Styles", required: false)
</head>
<body>
    <div class="cl-header container-fluid">
        <div class="header-content container">
            <nav class="navbar navbar-expand-lg navbar-light">
                <a class="navbar-brand" href="/home/index">
                    <img src="@(Logo??orgInfo.CurrentValue.Logo)" width="144" height="72" alt="">
                </a>
                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <div class="collapse navbar-collapse justify-content-end" id="navbarNav">
                    <ul class="navbar-nav">
                        <li class="nav-item @((Context.Request.Path == "/home"||Context.Request.Path == "/"||Context.Request.Path == ""  ) ? "active" : "")">
                            <a class="nav-link" href="/home">首页 
                                @if (Context.Request.Path == "/home"){ <span class="sr-only">(current)</span> }
                            </a>
                        </li>
                        @foreach (var item in categoryList)
                        {
                            var listUrl = $"/List/{item.Id}.html";
                            <li class="nav-item @(Context.Request.Path.Equals(listUrl, StringComparison.OrdinalIgnoreCase) ? "active" : "")">
                                <a class="nav-link" href="@listUrl">
                                    @item.Name
                                    @if (Context.Request.Path.Equals(listUrl, StringComparison.OrdinalIgnoreCase)){
                                        <span class="sr-only">(current)</span>
                                    }
                                </a>
                            </li>
                        }
                        <li class="nav-item @((Context.Request.Path == "/Details") ? "active" : "")">
                            <a class="nav-link" href="@($"/Details/{articleId}.html")">关于 
                                @if (Context.Request.Path == "/Details"){ <span class="sr-only">(current)</span> }
                            </a>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>
    <div class="cl-cantainer container">
        <div class="row">
            <div class="col-md-9 cl-left">
            @RenderBody()
            </div>
            <div class="col-md-3 cl-right">
                <div class="right-card">
                    <div class="right-card-main">
                        <div class="right-card-title">@wechart?.Label</div>
                        <div class="cl-code">
                            <img src="@wechart?.ExtData" class="img-fluid" alt="">
                            <p>@wechart?.Value</p>
                        </div>
                    </div>
                </div>
                <div class="right-card">
                    <div class="right-card-main">
                        <div class="right-card-title">@newrecomm?.Label</div>
                        <div class="right-recommended"><a><img src="@newrecomm?.ExtData" class="img-fluid" alt=""></a></div>
                        <ul class="right-recommended-list">
                            @foreach(var c in articleList)
                            {
                                <li>
                                    <a href="@($"/Details/{c?.Id}.html")">
                                        <i class="fa fa-angle-right" aria-hidden="true"></i>@Html.Raw(c?.Title)
                                    </a>
                                </li>
                            }
                        </ul>
                    </div>
                </div>
                <div class="right-card">
                    <div class="right-card-main">
                        <div class="right-card-title">热门标签</div>
                        <ul class="label">
                            @foreach (var item in tagList){<li><a href="">@item.Name</a></li>}
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="container-fluid cl-footer">
        <div class="container">
            <p class="cl-copyright">@Html.Raw(CopyRigth??orgInfo.CurrentValue.CopyRigth)</p>
        </div>
    </div>
    <script src="~/lib/jquery/jquery.min.js"></script>
    <script src="~/lib/bootstrap/js/bootstrap.min.js"></script>
    <script src="~/lib/highlight/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    @await RenderSectionAsync("Scripts", required: false)
</body>
</html>